<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>粉丝管理</title>
    <link href="<{$ipath}>user/style/my_service_css.css" type="text/css" rel="stylesheet">
    <link href="<{$ipath}>app/hotel/style/room_css.css" type="text/css" rel="stylesheet">
    <script src="<{$ipath}>public/js/jquery.js"></script>
    <style>
        td img{max-height:80px;}
        .page a{display:inline;}
		#shade{
	position: absolute;
	z-index: 100;
	height: 100%;
	width: 100%;
	left: 0px;
	top: 0px;
	background-color: #000;
	filter: alpha(opacity=40);
	-moz-opacity: 0.4;
	-khtml-opacity: 0.4;
	opacity: 0.4;
	display:none;
}
#showedit{
	background-color: #000;
	border: 1px solid #000;
	position:fixed;
	z-index: 999;
	width: 50%;
	border-radius: 5px;
	padding: 3px;
	display:none;
	-moz-box-shadow:0 0 30px rgba(0, 0, 0, .5);
	-webkit-box-shadow:0 0 30px rgba(0, 0, 0, .5);
	box-shadow:0 0 30px rgba(0, 0, 0, .5);
}
#showedit .showcon{
	background-color: #FFF;
	overflow: hidden;
}
#showedit .put{
	line-height: 20px;
	vertical-align: middle;
	height: 20px;
	padding-right: 10px;
	padding-left: 10px;
	border: 1px solid #CCC;
}
#showedit #contit,#showedit #coninput{
	margin-top: 20px;
	margin-bottom: 20px;
}

#showedit .subbutton{
	background:#44b549;
	vertical-align: middle;
	height: 32px;
	width: 106px;
	font-family: "微软雅黑", "黑体", "宋体";
	font-weight: normal;
	color: #FFF;
	border: 1px solid #dadbe0;
	text-align: center;
	cursor: pointer;
	border-radius: 5px;
	display:inline-block;
	line-height:32px;
}
.creatgroup{
	display: inline-block;
	float: right;
}
#showedit .showcon .con{}
.servicebox{ position:relative;}
.load{ position:absolute; top:20%;left:40%; background:url(<{$ipath}>wx/images/loading.gif); width:33px;height:33px; display:none;}
.content{ overflow:scroll;}
.bg{background:rgba(204,204,204,0.5); width:100%;height:100%; position:absolute; left:0;top:0; display:none;}
.content{ position:absolute;z-index:2; width:30%; height:300px; border:5px solid #000; border-radius:10px;  background:#fff; margin:10% 30%; }
.rush{ background:url(<{$ipath}>wx/images/53d4e66c070fe141c0598af11ad9d159.jpg) -12px -39px no-repeat; width:12px; height:13px; float:right; margin:5px 30px;}
.subbutton{ display:inline-block; background:none; width:20%; height:30px; background:rgba(102,204,102,1); border:0; font-size:20px; text-align:center; line-height:30px; color:#fff; margin-left:38px;}
.nick{width:200px;border:1px solid #ccc;height:26px;line-height:24px;margin-left: 13px;margin-top: 10px;}
.seacher{    cursor:pointer;display: inline-block;  border-top: 1px solid #ccc;
	border-right: 1px solid #ccc;
	border-bottom: 1px solid #ccc;
	height: 28px;
	width: 40px;
	margin-left: -5px;
	color: rgba(142, 130, 130, 0.92);
	background-color: white;}
.sel{float: left;margin-top: 10px;margin-left: 10px;border: 1px solid #ccc;height: 28px; width: 90px;}
	</style>
</head>
<script>
	var i=0;
	var listids = new Array();
	function aa(){
		if($('.all').is(':checked')){
			$('.all').prop('checked', 'checked');
			$('.divid').prop('checked', 'checked');
			$('.sel').removeAttr('disabled');
			var len = $(".divid:checked").length;
			for(i=0;i<len;i++){
				listids[i]  = $(".divid:checked").eq(i).val();
			}
			console.log(listids);
		}else if (!$('.all').is(':checked')) {
			$('.all').removeAttr('checked');
			$('.divid').removeAttr('checked');
			$('.sel').prop('disabled', 'disabled');
			listids.splice(0,listids.length);
		};
	};
	function bb(){
		if($('.divid').is(':checked')){
			$('.sel').removeAttr('disabled');
			var len = $(".divid:checked").length;
			for(i=0;i<len;i++){
				listids[i]  = $(".divid:checked").eq(i).val();
				console.log(listids);
			}
		}else if(!$('.divid').is(':checked')){
			$('.sel').prop('disabled', 'disabled');
			listids.splice(0,listids.length);
		}
	}


</script>
<body>
<div class="servicebox">
	
    <div class="bg">
        <div class="content">
            <ul>
             <{foreach item=v from=$group}>
                <li onMouseOver="move(this)" onMouseOut="out(this)" value="<{$v.id}>" <{if $list[l].groupid==$v.id}>selected<{/if}>><{$v.name}><i onClick="del(this)"></i></li>
             <{/foreach}>
            </ul>
            <input type="submit" class="subbutton" value="保 存" onClick="deltrue(this)">
            <input class="group" type="hidden" name="groupid" value="<{$list[l].openid}>"/>
            <a href="javascript:;" class="subbutton" onClick="debtn()" >取 消</a>
        </div>
    </div>
	<div class="load"></div>
    <!--内容-->
    <P class="caption">粉丝管理</P>
    <div class="content01">
        <div class="caibox" style="min-height:680px;">
           <p class="title p_03">粉丝管理<em><a href="javascript:;" onClick="showdel()" class="creatgroup">删除分组</a>
				   <a onClick="showedit(1)" class="creatgroup">创建分组</a> |
				   <a style="display:inline" href="?g=wx&m=weixin&a=updateguest" target="hiddfrm" onClick="loading()">更新粉丝信息</a>
				   </em></p>

			<select class="sel" disabled onChange="numchange($(this).find('option:selected').val(),listids)" >

				<{foreach item=v from=$group}>
				<option value="<{$v.id}>"  ><{$v.name}></option>
				<{/foreach}>
			</select>

				<form action="index.php?g=wx&m=weixin&a=fenlist" method="post"><input type="text" class="nick" name="nick_name" placeholder="粉丝昵称" value=""/>
					<input type="submit" value="搜索" class="seacher"></form>

            
            <!--内容94%-->
            <div class="roombox">
                <table class="order_room" cellspacing="0">
                    <tr class="tr01">
						<td ><input type="checkbox" class="all" onchange="aa()" value="" >全选</td>
                        <td>编号</td>
                        <td>粉丝昵称</td>
                        <td>备注昵称</td>
                        <td>性别</td>
                        <td>省（直辖市）</td>
                        <td>城市</td>
                        <td>头像</td>
                        <td>组别</td>
                        <td>备注</td>
                    </tr>
                    <{section name=l loop=$list}>
                    <tr class="tr02">
						<td><input type="checkbox"  class="divid" onchange="bb()" value="<{$list[l].openid}>" ></td>
                        <td><{$list[l].id}></td>
                        <td><{$list[l].uname}></td>
                        <td id="remark<{$list[l].id}>"><{$list[l].remark}></td>
                        <td><{$list[l].sex}></td>
                        <td><{$list[l].province}></td>
                        <td><{$list[l].city}></td>
                        <td class="td_img"><img src="<{$list[l].uface}>"></td>
                        <td >
                            <input class="openid" type="hidden" name="openid" value="<{$list[l].openid}>"/>
                            <select class="chagegroup" onChange="putusergroup(this.value,'<{$list[l].openid}>')" style="border: 1px solid #ccc;height: 28px;    width: 100px;">
                            <{foreach item=v from=$group}>
                                <option value="<{$v.id}>" <{if $list[l].groupid==$v.id}>selected<{/if}>><{$v.name}></option>
                                
                            <{/foreach}>
                            </select>
                        </td>
                        <td ><a onclick="showedit(2,<{$list[l].id}>)" style="border: 1px solid #ccc;height: 28px;line-height: 28px;">修改备注</a></td>
                    </tr>
                    <{/section}>

                </table>
                <ul class="page">
                    <{$pagestr}>
                </ul>
            </div>
        </div>
    </div>

</div>

</div>
<div id="shade" onClick="show()"></div>
    <div id="showedit">
        <div class="showcon">
          <ul class="con">
          <form action="" id="editfrm" method="post" target="hiddfrm">
          	<li id="contit"></li>
            <li id="coninput"></li>
            <li><input type="submit" class="subbutton" value="确定" onClick="show()"/> <input type="button"  class="subbutton" value="取消" onClick="show()" /></li>
           </form>
          </ul>
      </div>
    </div>
<script>


function showdel(){
	$(".bg").show();
}
function show(boolean){
	var obj = $("#showedit");
		t = obj.offset().top+obj.height()/2;
		l = ($(window).width() - obj.width()) / 2;
	if(boolean){
		$('#shade').show();
		obj.css({
			"top" : t+"px",
			"left": l+"px"
		}).show();
	} else {
		$('#shade').hide();
		obj.hide();
	}
}
function showedit(n,id){
	if(n==1){
		$("#contit").html("创建分组");
		$("#coninput").html('分组名称：<input type="text" class="put" name="group_name" />');
		$("#editfrm").attr("action","?g=wx&m=weixin&a=fans_group");
	}else if(n==2){
		$("#contit").html("修改备注");
		$("#coninput").html('备注名称：<input type="text" class="put" name="uname" value="'+$("#remark"+id).html()+'"/> <input type="hidden" name="id" value="'+id+'" />');
		$("#editfrm").attr("action","?g=wx&m=weixin&a=updata_nick");
	}else{
		return false;
	}
	show(true);
}
function saveremark(str,id){
	$("#remark"+id).html(str);
	show();
}
function numchange(groupid,listids){
	var url='?g=wx&m=weixin&a=mvoe_num';
	var data={};
	data.listids=listids;
	data.groupid = groupid;
	//console.log(listids);
	console.log(listids);
	$.post(url,data,function(data){
		alert('批量修改分组成功');
		location.href="?g=wx&m=weixin&a=fenlist";
	});
}
function putusergroup(val,id){
	var url='?g=wx&m=weixin&a=updata_group';
	var data={};
	data.openid=id;
	data.groupid=val;
	$.post(url,data,function(data){
			alert('修改分组成功');
	})
}
function remove(obj){
	$(obj).parent().remove();	
}
function loading(){		
  $(".load").show();
 // fansup();
}
function fansup(){
	alert("更新粉丝信息成功！");
	location.href='?g=wx&m=weixin&a=fenlist';
}
function move(obj){
	$(obj).find("i").addClass("rush");
}
function out(obj){
	$(obj).find("i").removeClass("rush")	
}
var i=0;
var group_id=new Array();
function del(obj){
	
	var idSave=$(obj).parent().val();
	$(obj).parent().remove();
	group_id[i++]=idSave;
	console.log(group_id);
	console.log(group_id.length);
	
}
function deltrue(obj){
	var data={};
	data.groupid=group_id;
	$.post("?g=wx&m=weixin&a=del_group",data,function(){
		$(obj).parent().parent().hide();
		window.location.href='?g=wx&m=weixin&a=fenlist';
	});	
}
function debtn(){
	$(".bg").hide();
	window.location.href='?g=wx&m=weixin&a=fenlist';	
}

</script>
</body>
</html>

<iframe width="0" height="0" scrolling="no" frameborder="0" name="hiddfrm" id="hiddfrm" style="display:none"></iframe>
</body>
</html>
